package com.cyj.springbootservice.controller.profileloading;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @description:
 * @Author C_Y_J
 * @create 2021/9/28 10:41
 **/
@RestController
@RequestMapping("/person")
public class PersonController {

    @Value("${person1.name}")
    private String name1;

    @Value("${person2.name}")
    private String name2;

    @Value("${address1[0]}")
    private String address1;

    @Value("${address1[1]}")
    private String address2;

    @Value("${msg1}")
    private String msg1;

    @Value("${msg2}")
    private String msg2;

    @Autowired
    private Person person;

    @Autowired
    private Environment environment;

    @GetMapping("/detail")
    public void detail() {
        System.out.println(name1);
        System.out.println(name2);
        System.out.println(address1);
        System.out.println(address2);
        System.out.println(msg1);
        System.out.println(msg2);
        System.out.println("######################################");
        System.out.println(person);
        System.out.println("######################################");
        System.out.println(environment.getProperty("person1.name"));
        System.out.println(environment.getProperty("person2.name"));
        System.out.println(environment.getProperty("address1[0]"));
        System.out.println(environment.getProperty("{address1[1]"));
        System.out.println(environment.getProperty("msg1"));
        System.out.println(environment.getProperty("msg2"));
        System.out.println("######################################");
    }
}
